FROM swr.cn-east-2.myhuaweicloud.com/dc/openjdk:21-oracle AS builder
WORKDIR /application
COPY ./target/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract && rm app.jar

FROM swr.cn-east-2.myhuaweicloud.com/dc/openjdk:21-oracle
LABEL authors="dc_team"
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /application
COPY --from=builder /application/dependencies/ ./
COPY --from=builder /application/snapshot-dependencies/ ./
COPY --from=builder /application/spring-boot-loader/ ./
COPY --from=builder /application/application/ ./
COPY ./bin/entrypoint.sh /application/entrypoint.sh
RUN chmod +x /application/entrypoint.sh

EXPOSE 8080
ENTRYPOINT ["/application/entrypoint.sh"]
